<?php
/**
 * Created by PhpStorm.
 * User: zd
 * Date: 2018/11/8
 * Time: 11:02
 */

namespace app\api\behavior;


use app\api\model\Behavior;
use app\api\model\Behavior01;
use app\api\model\Behavior02;
use app\api\model\Behavior03;
use app\api\model\Behavior04;

class BaseBehavior
{
    /**
     * 获取行为模型
     * @param $tag
     * @return Behavior01
     */
    protected function getBehavior($tag){
//        $behavior = '';
//        if ($tag == 0){
//            $behavior = new Behavior01();
//        }elseif($tag == 1){
//            $behavior = new Behavior02();
//        }elseif($tag == 2){
//            $behavior = new Behavior03();
//        }elseif ($tag == 3){
//            $behavior = new Behavior04();
//        }
        $behavior = new Behavior();
        return $behavior;
    }

    /**
     * 要返回的数据结构
     * @param $data
     * @param $result
     * @return mixed
     */
    protected function getMassgeInfo($data,$result){
        $info['id'] = $data->id;
        $info['url'] = $data->avatar_url;
        $info['nickname'] = $data->nickname;
        $info['time'] = date("Y-m-d H:i:s",$result->add_time);
        $info['times'] = $result->times;
        $info['content'] = $result->content;
        $info['year'] = date("Y-m-d",$result->add_time);
        return json_encode($info);
    }
}